local skel = fk.CreateSkill {
  name = "emo__ziduoyin",
}

Fk:loadTranslationTable{
  ["emo__ziduoyin"] = "自堕轮回阿鼻",
  [":emo__ziduoyin"] = "你可以将基本牌当作此法转化过的锦囊牌使用或打出。",
}

--- 可以转化的牌名
---@param player Player
local getNames = function (player)
  local names = {}
  for _, v in pairs(player:getTableMark("emo__ziduolh_record")) do
    table.insertTableIfNeed(names, v)
  end
  return player:getViewAsCardNames(skel.name, names)
end

skel:addEffect("viewas", {
  pattern = ".|.|.|.|.|trick",
  prompt = "#emo__ziduolh-yin",
  handly_pile = true,
  interaction = function(self, player)
    local choices = getNames(player)
    if #choices > 0 then
      return UI.CardNameBox { choices = choices }
    end
  end,
  card_filter = function (self, player, to_select, selected)
    if #selected ~= 0 then return false end
    return Fk:getCardById(to_select).type == Card.TypeBasic
  end,
  view_as = function (self, player, cards)
    if #cards ~= 1 or Fk.all_card_types[self.interaction.data] == nil then return nil end
    local c = Fk:cloneCard(self.interaction.data)
    c.skillName = skel.name
    c:addSubcard(cards[1])
    return c
  end,
  enabled_at_play = function(self, player)
    return #getNames(player) > 0
  end,
  enabled_at_response = function (self, player, response)
    return #getNames(player) > 0
  end,
})

return skel
